#!/usr/bin/python
'''
@author: Aurelien Deharbe


This file is part of Cute-Server.

Cute-Server is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Cute-Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Cute-Server.  If not, see <http://www.gnu.org/licenses/>.
'''

from cuteserver import cserver
import ConfigParser
import os
import getopt
import sys

if __name__ == '__main__':
    
    port = 5000
    
    try:
        config = ConfigParser.ConfigParser()
        config.read(os.path.expanduser("~") + "/.cuteconf")
        try:
            port = config.getint('general', 'port')
        except:
            pass
    except:
        pass
    
    try:
        opts, args = getopt.getopt(sys.argv[1:], "p:", ["port="])
        for opt, arg in opts:
            if opt in ("-p", "--port"):
                port = int(arg)
    except getopt.GetoptError:
        pass
    
    cserver.cserver(port)
